<?php 

/*新品展区*/

class NewgoodsAction extends GlobalAction{	
	function _initialize(){			 
		 parent::_initialize();
		 //加载产品相关函数库		 
		 LC('@.Help.myfuns');
		 $this->cate_id(0);		
	}	 
	//获取所有小分类id;
	public function getcatids(){
	   $catAllList=cat_list($this->cid);
	   $cat_ids=array();
	   foreach($catAllList as $k=>$v){
			$cat_ids[]=$v['id'];
	   }
	   $cat_ids=implode(",", $cat_ids);	
	   return $cat_ids;
	}
	//首页显示分类;	 
	public function index(){
		 $filter=$this->getfilter();
		 $filter['cl']="1,20,2,2,Newgoods,0,";
		 $url=U('mclist',$filter);		
		  mdl_header("Location: $url \n");
		 exit;	  
	} 	
	//显示列表;
	public function mclist(){		 
		$filter=$this->getfilter();
		//dump($filter);
		$cl=$this->getby('cl');
		//dump($cl);
		if(empty($cl)){			 
		//$_SESSION["goods_filter"]='';
		}
		//dump($this->getbyarams());
		if(!$this->getbyarams()){
		   U('Default/index','',true);
		}
        $cat_id=$this->getby('cat');
		$cat_id =  empty($cat_id) ? $this->cid : intval($cat_id);
	 //echo $cat_id;
		$list = $this->getAllGoods($cat_id,$filter);
	 
	   ///$list=$this->getAllShow($this->getcatids(),$filter);	   
	   //$list['cat_list']=$catGoodsList;
	   if($cat_id==0){
			$temp=array();
			foreach($list['cat_list'] as $key=>$val){
			    if($val['level']==1){
				  $temp[]=$val;
				}
			
			};
			$list['cat_list']=$temp;

       }
	   $list['day_list']=get_day_list();
	   $this->assign('nav_url',navurl('Newsgoods'));
	   $f=unserialize(urldecode($_SESSION["goods_filter"]));
	   $cat_name= get_nav_cat_name();
	   $this->assign('cat_name','&nbsp;&nbsp;新品');
		//dump($list['cat_list']); 
	   $this->assign($list);
	   $no_list=$this->getsearchno();	
	   $this->assign($no_list); 	   
   	   $this->assign($filter);	
	   $this->get_orderby_psize('Newsgoods');
       $this->display();	
	}


}
?>